package com.tiancheng.trade.payment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tiancheng.trade.commom.core.enums.SettleStatusEnum;
import com.tiancheng.trade.payment.mapper.PaymentFlowDetailSettleDetailMapper;
import com.tiancheng.trade.payment.mapper.PaymentFlowDetailSettleMapper;
import com.tiancheng.trade.payment.model.PaymentFlowDetailSettle;
import com.tiancheng.trade.payment.model.PaymentFlowDetailSettleDetail;
import com.tiancheng.trade.payment.service.IPaymentFlowDetailSettleDetailService;
import com.tiancheng.trade.payment.service.PaymentFlowDetailSettleService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @Author: kellen
 * @Description: 结算明细
 * @Date: create in 2024/12/10 19:43
 */
@Service
public class PaymentFlowDetailSettleDetailServiceImpl extends ServiceImpl<PaymentFlowDetailSettleDetailMapper, PaymentFlowDetailSettleDetail> implements IPaymentFlowDetailSettleDetailService {

    @Override
    public List<PaymentFlowDetailSettleDetail> queryWaitSettleDetailsBySettleIds(Set<Long> settleIds) {
        return this.list(new LambdaQueryWrapper<PaymentFlowDetailSettleDetail>().in(PaymentFlowDetailSettleDetail::getSettleId, settleIds)
                .in(PaymentFlowDetailSettleDetail::getSettleStatus, new ArrayList<>() {{
                    add(SettleStatusEnum.WAIT.getCode());
                    add(SettleStatusEnum.FAIL.getCode());
                }}));
    }

    @Override
    public List<PaymentFlowDetailSettleDetail> listBySettleIds(Set<Long> settleIds) {
        return this.list(new LambdaQueryWrapper<PaymentFlowDetailSettleDetail>().in(PaymentFlowDetailSettleDetail::getSettleId, settleIds));
    }
}
